package avicit.cbb.techclass.billdefine.action.rest;


import avicit.cbb.techclass.billdefine.action.service.BillDefineManagerService;
import avicit.cbb.techclass.billdefine.domain.CbbTabFormConfig;
import avicit.cbb.techclass.tabledefine.commtablemanager.domain.CbbTabColumns;
import avicit.cbb.techclass.tabledefine.commtempletmanager.action.rest.CommTempletManagerRest;
import avicit.cbb.techclass.tabledefine.commtempletmanager.domain.CbbTempletCode;
import avicit.platform6.core.context.ThreadContextHelper;
import avicit.platform6.core.dao.Paging;
import avicit.platform6.core.jdbc.Page;
import avicit.platform6.core.rest.msg.ResponseMsg;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @金航数码科技有限责任公司
 * @作者：jiam
 * @邮箱：jiam@avic-digital.com
 * @创建时间： 2020-12-31 14:52
 * @类说明：oa_travel_rbRest
 * @修改记录：
 */

@RestController
@Api(tags = "BillDefineManagerService", description = "BillDefine_Manager_Service")
@RequestMapping("/api/avicit/cbb/techclass/billdefine/action/rest/BillDefineManagerRest")
public class BillDefineManagerRest {



    private static final Logger LOGGER = LoggerFactory.getLogger(BillDefineManagerRest.class);


    @Autowired
    private BillDefineManagerService billDefineManagerService;

    /**
     *  基本字段查询对象
     * @param map
     * @return
     */
    @PostMapping("/getFormShowTableList")
    @ApiOperation(value = "基本字段查询对象")
    public ResponseMsg<List<CbbTabColumns>> getFormShowTableList(@ApiParam(value = "基本字段查询对象", name = "map") @RequestBody Map<String, Object> map) {
        ResponseMsg<List<CbbTabColumns>> responseMsg = new ResponseMsg<>();
        List<CbbTabColumns> formShowTableList = null;
        try {
            String tableId = (String) map.get("tableId");
            String s = (String) map.get("s");
            String tableName = (String) map.get("tableName");
            String s1 = (String) map.get("s1");
            String sysId = (String) map.get("sysId");
            String orgId = (String) map.get("orgId");
            String deptId = (String) map.get("deptId");
            formShowTableList = billDefineManagerService.getFormShowTableList(tableId, "", tableName, "4", sysId, orgId,
                    deptId);
            responseMsg.setResponseBody(formShowTableList);
            responseMsg.setRetCode("200");
        } catch (Exception e) {
            responseMsg.setRetCode("201");
            responseMsg.setErrorDesc(e.getMessage());
            e.printStackTrace();
        }
        return responseMsg;
    }

    /**
     * 根据表ID,节点ID判断表单是否存在
     * @param map
     * @return
     */
    @PostMapping("/checkHasForm")
    @ApiOperation(value = "根据表ID,节点ID判断表单是否存在")
    public ResponseMsg<Boolean> checkHasForm(@ApiParam(value = "根据表ID,节点ID判断表单是否存在", name = "map") @RequestBody Map<String, Object> map) {
        ResponseMsg<Boolean> responseMsg = new ResponseMsg<>();
        boolean b = false;
        try {
            String tableId = (String) map.get("tableId");
            String nodeId = (String) map.get("nodeId");
            String archiveStatus = (String) map.get("archiveStatus");
            b = billDefineManagerService.checkHasForm(tableId, nodeId, archiveStatus);
            responseMsg.setResponseBody(b);
            responseMsg.setRetCode("200");
        } catch (Exception e) {
            responseMsg.setRetCode("201");
            responseMsg.setErrorDesc(e.getMessage());
            e.printStackTrace();
        }

        return responseMsg;
    }


    /**
     * 根据表ID,节点ID判断表单是否存在
     * @param map
     * @return
     */
    @PostMapping("/checkHasForm2")
    @ApiOperation(value = "根据表ID,节点ID判断表单是否存在")
    public ResponseMsg<Boolean> checkHasForm2(@ApiParam(value = "根据表ID,节点ID判断表单是否存在", name = "map") @RequestBody Map<String, Object> map) {
        ResponseMsg<Boolean> responseMsg = new ResponseMsg<>();
        boolean b = false;
        try {
            String tableId = (String) map.get("tableId");
            String nodeId = (String) map.get("nodeId");
            b = billDefineManagerService.checkHasForm(tableId, nodeId);
            responseMsg.setResponseBody(b);
            responseMsg.setRetCode("200");
        } catch (Exception e) {
            responseMsg.setRetCode("201");
            responseMsg.setErrorDesc(e.getMessage());
            e.printStackTrace();
        }

        return responseMsg;
    }


    /**
     * 获取表单配置信息中的列信息
     * @param map
     * @return
     */
    @PostMapping("/getPageBillFormConfigList")
    @ApiOperation(value = "获取表单配置信息中的列信息")
    public ResponseMsg<Page<Map<String, Object>>> getPageBillFormConfigList(@ApiParam(value = "获取表单配置信息中的列信息", name = "map") @RequestBody Map<String, Object> map) {
        ResponseMsg<Page<Map<String, Object>>> responseMsg = new ResponseMsg<>();
        Page<Map<String, Object>> pageBillFormConfigList = null;
        try {
            Paging<CbbTempletCode> page = (Paging<CbbTempletCode>) map.get("page");
            Map<String, Object> parameter = (Map<String, Object>) map.get("parameter");
            pageBillFormConfigList = (Page<Map<String, Object>>) billDefineManagerService.getPageBillFormConfigList(page, parameter);
            responseMsg.setResponseBody(pageBillFormConfigList);
            responseMsg.setRetCode("200");
        } catch (Exception e) {
            responseMsg.setRetCode("201");
            responseMsg.setErrorDesc(e.getMessage());
            e.printStackTrace();
        }

        return responseMsg;
    }


    /**
     * 获取模版库表单列信息
     * @param map
     * @return
     */
    @PostMapping("/getPageBillDbList")
    @ApiOperation(value = "获取模版库表单列信息")
    public ResponseMsg<Page<Map<String, Object>>> getPageBillDbList(@ApiParam(value = "获取模版库表单列信息", name = "map") @RequestBody Map<String, Object> map) {
        ResponseMsg<Page<Map<String, Object>>> responseMsg = new ResponseMsg<>();
        Page<Map<String, Object>> pageBillDbList = null;
        try {
            Paging<CbbTempletCode> page = (Paging<CbbTempletCode>) map.get("page");
            Map<String, Object> parameter = (Map<String, Object>) map.get("parameter");
            String orgId = (String) map.get("orgId");
            pageBillDbList = billDefineManagerService.getPageBillDbList(page, parameter, orgId);
            responseMsg.setResponseBody(pageBillDbList);
            responseMsg.setRetCode("200");
        } catch (Exception e) {
            responseMsg.setRetCode("201");
            responseMsg.setErrorDesc(e.getMessage());
            e.printStackTrace();
        }
        responseMsg.setResponseBody(pageBillDbList);
        return responseMsg;
    }

    /**
     * 判断表单管理树节点对应表是否有数据
     * @param tableId
     * @return
     */
    @PostMapping("/getTableDataCount")
    @ApiOperation(value = "判断表单管理树节点对应表是否有数据")
    public ResponseMsg<Integer> getTableDataCount(@ApiParam(value = "判断表单管理树节点对应表是否有数据", name = "tableId") @RequestBody String tableId) {
        ResponseMsg<Integer> responseMsg = new ResponseMsg<>();
        int tableDataCount = 0;
        try {
            tableDataCount = billDefineManagerService.getTableDataCount(tableId);
            responseMsg.setResponseBody(tableDataCount);
            responseMsg.setRetCode("200");
        } catch (Exception e) {
            responseMsg.setRetCode("201");
            responseMsg.setErrorDesc(e.getMessage());
            e.printStackTrace();
        }

        return responseMsg;
    }


    /**
     * 更新表单配置表信息
     * @param cbbTabFormConfig
     * @return
     */
    @PostMapping("/updateCbbTabForm")
    @ApiOperation(value = "更新表单配置表信息")
    public ResponseMsg updateCbbTabForm(@ApiParam(value = "更新表单配置表信息", name = "cbbTabFormConfig") @RequestBody CbbTabFormConfig cbbTabFormConfig) {
        ResponseMsg responseMsg = new ResponseMsg();
        try {
            billDefineManagerService.updateCbbTabForm(cbbTabFormConfig);
            responseMsg.setRetCode("200");
        } catch (Exception e) {
            responseMsg.setRetCode("201");
            responseMsg.setErrorDesc(e.getMessage());
            e.printStackTrace();
        }
        return responseMsg;
    }

    /**
     * 创建表单信息 参数：系统标识ID，节点ID，节点名称，库表ID
     * @param map
     */
    @PostMapping("/createCbbTabForm")
    @ApiOperation(value = "创建表单信息 参数：系统标识ID，节点ID，节点名称，库表ID")
    public ResponseMsg createCbbTabForm(@ApiParam(value = "创建表单信息 参数：系统标识ID，节点ID，节点名称，库表ID", name = "map") @RequestBody Map<String,Object> map) {
        ResponseMsg responseMsg = new ResponseMsg();
        try {
            String sysId = (String) map.get("sysId");
            String nodeName = (String) map.get("nodeName");
            String orgId = (String) map.get("orgId");
            String deptId = (String) map.get("deptId");
            String tableId = (String) map.get("tableId");
            String nodeId = (String) map.get("nodeId");
            String json = (String) map.get("json");
            String archiveStatus = (String) map.get("archiveStatus");
            billDefineManagerService.createCbbTabForm(sysId, nodeName, orgId, deptId, tableId, nodeId, json,archiveStatus);
            responseMsg.setRetCode("200");
        } catch (Exception e) {
            responseMsg.setRetCode("201");
            responseMsg.setErrorDesc(e.getMessage());
            e.printStackTrace();
        }
        return responseMsg;
    }

    /**
     * 表单管理重置
     * @param map
     */
    @PostMapping("/resetFormDataByArchiveFormId")
    @ApiOperation(value = "表单管理重置")
    public ResponseMsg resetFormDataByArchiveFormId(@ApiParam(value = "表单管理重置", name = "map") @RequestBody Map<String,Object> map) {
        ResponseMsg responseMsg = new ResponseMsg();
        try {
            String sysId = (String) map.get("sysId");
            String nodeId = (String) map.get("nodeId");
            String tableId = (String) map.get("tableId");
            String archiveStatus = (String) map.get("archiveStatus");
            billDefineManagerService.resetFormDataByArchiveFormId(sysId,nodeId,tableId,archiveStatus);
            responseMsg.setRetCode("200");
        } catch (Exception e) {
            responseMsg.setRetCode("201");
            responseMsg.setErrorDesc(e.getMessage());
            e.printStackTrace();
        }
        return responseMsg;
    }

    @PostMapping("/resetFormDataByFormId")
    @ApiOperation(value = "表单管理重置")
    public ResponseMsg resetFormDataByFormId(@ApiParam(value = "表单管理重置", name = "map") @RequestBody Map<String,Object> map) {
        ResponseMsg responseMsg = new ResponseMsg();
        try {
            String sysId = (String) map.get("sysId");
            String nodeId = (String) map.get("nodeId");
            String tableId = (String) map.get("tableId");
            billDefineManagerService.resetFormDataByFormId(sysId,nodeId,tableId);
            responseMsg.setRetCode("200");
        } catch (Exception e) {
            responseMsg.setRetCode("201");
            responseMsg.setErrorDesc(e.getMessage());
            e.printStackTrace();
        }
        return responseMsg;
    }



    @PostMapping("/createCbbTabForm2")
    @ApiOperation(value = "表单管理重置")
    public ResponseMsg createCbbTabForm2(@ApiParam(value = "表单管理重置", name = "map") @RequestBody Map<String,Object> map) {
        ResponseMsg responseMsg = new ResponseMsg();
        try {
            String sysId = (String) map.get("sysId");
            String nodeName = (String) map.get("nodeName");
            String orgId = (String) map.get("orgId");
            String deptId = (String) map.get("deptId");
            String tableId = (String) map.get("tableId");
            String nodeId = (String) map.get("nodeId");
            String json = (String) map.get("json");
            billDefineManagerService.createCbbTabForm(sysId, nodeName, orgId, deptId, tableId, nodeId, json);
            responseMsg.setRetCode("200");
        } catch (Exception e) {
            responseMsg.setRetCode("201");
            responseMsg.setErrorDesc(e.getMessage());
            e.printStackTrace();
        }
        return responseMsg;
    }


    /**
     * 获取模板列数
     * @param param
     * @return
     */
    @PostMapping("/getModelColumn")
    @ApiOperation(value = "获取模板列数")
    public ResponseMsg<String> getModelColumn(@ApiParam(value = "获取模板列数", name = "param") @RequestBody Map<String,Object> param) {
        ResponseMsg<String> responseMsg = new ResponseMsg<>();
        String modelColumn = null;
        try {
            modelColumn = billDefineManagerService.getModelColumn(param);
            responseMsg.setResponseBody(modelColumn);
            responseMsg.setRetCode("200");
        } catch (Exception e) {
            responseMsg.setRetCode("201");
            responseMsg.setErrorDesc(e.getMessage());
            e.printStackTrace();
        }
        return responseMsg;

    }


    /**
     * 设置模版列数
     * @param param
     */
    @PostMapping("/setModelColumn")
    @ApiOperation(value = "表单管理重置")
    public ResponseMsg setModelColumn(@ApiParam(value = "表单管理重置", name = "param") @RequestBody Map<String,Object> param) {
        ResponseMsg responseMsg = new ResponseMsg();
        try {
            billDefineManagerService.setModelColumn(param);
            responseMsg.setRetCode("200");
        } catch (Exception e) {
            responseMsg.setRetCode("201");
            responseMsg.setErrorDesc(e.getMessage());
            e.printStackTrace();
        }
        return responseMsg;
    }


    /**
     * 根据表单配置ID获取该对象
     * @param formConfigId
     * @return
     */
    @PostMapping("/getcbbTabFormConfigById")
    @ApiOperation(value = "表单管理重置")
    public ResponseMsg<CbbTabFormConfig> getcbbTabFormConfigById(@ApiParam(value = "表单管理重置", name = "param") @RequestBody String formConfigId) {
        ResponseMsg responseMsg = new ResponseMsg();
        try {
            CbbTabFormConfig cbbTabFormConfig = billDefineManagerService.getcbbTabFormConfigById(formConfigId);
            responseMsg.setResponseBody(cbbTabFormConfig);
            responseMsg.setRetCode("200");
        } catch (Exception e) {
            responseMsg.setRetCode("201");
            responseMsg.setErrorDesc(e.getMessage());
            e.printStackTrace();
        }
        return responseMsg;
    }



//    /**
//     *
//     * @param resMapsRb
//     * @return
//     */
//    @PostMapping("/createCbbTabForm/v1")
//    @ApiOperation(value = "")
//    public ResponseMsg createCbbTabForm(@ApiParam(value = "", name = "filevitalizationservice")@RequestBody Map<String,Object> resMapsRb) {
//        ResponseMsg responseMsg = new ResponseMsg<>();
//        try {
//            String sysId = (String) resMapsRb.get("sysId");
//            String nodeName = (String) resMapsRb.get("nodeName");
//            String orgId = (String) resMapsRb.get("orgId");
//            String deptId = (String) resMapsRb.get("deptId");
//            String tableId = (String) resMapsRb.get("tableId");
//            String nodeId = (String) resMapsRb.get("nodeId");
//            String json = (String) resMapsRb.get("json");
//            String archiveStatus = (String) resMapsRb.get("archiveStatus");
//            billDefineManagerService.createCbbTabForm(sysId,nodeName,orgId,deptId,tableId,nodeId,json,archiveStatus);
//            responseMsg.setRetCode("200");
//        } catch (Exception e) {
//            responseMsg.setErrorDesc(e.getMessage());
//            responseMsg.setRetCode("201");
//            e.printStackTrace();
//        }
//        return responseMsg;
//    }




//    /**
//     *
//     * @param resMapsRb
//     * @return
//     */
//    @PostMapping("/createCbbTabForm/v1")
//    @ApiOperation(value = "")
//    public ResponseMsg createCbbTabForm(@ApiParam(value = "", name = "filevitalizationservice")@RequestBody Map<String,Object> resMapsRb) {
//        ResponseMsg responseMsg = new ResponseMsg<>();
//        try {
//            String sysId = (String) resMapsRb.get("sysId");
//            String nodeName = (String) resMapsRb.get("nodeName");
//            String orgId = (String) resMapsRb.get("orgId");
//            String deptId = (String) resMapsRb.get("deptId");
//            String tableId = (String) resMapsRb.get("tableId");
//            String nodeId = (String) resMapsRb.get("nodeId");
//            String json = (String) resMapsRb.get("json");
//            billDefineManagerService.createCbbTabForm(sysId,nodeName,orgId,deptId,tableId,nodeId,json);
//            responseMsg.setRetCode("200");
//        } catch (Exception e) {
//            responseMsg.setErrorDesc(e.getMessage());
//            responseMsg.setRetCode("201");
//            e.printStackTrace();
//        }
//        return responseMsg;
//    }




//    /**
//     *
//     * @param resMapsRb
//     * @return
//     */
//    @PostMapping("/getPageBillFormConfigList/v1")
//    @ApiOperation(value = "")
//    public ResponseMsg<com.github.pagehelper.Page<Map<String, Object>>> getPageBillFormConfigList(@ApiParam(value = "", name = "filevitalizationservice")@RequestBody Map<String,Object> resMapsRb) {
//        ResponseMsg<com.github.pagehelper.Page<Map<String, Object>>> responseMsg = new ResponseMsg<>();
//        try {
//            avicit.platform6.core.dao.Paging<avicit.cbb.techclass.tabledefine.commtempletmanager.domain.CbbTempletCode> page = (avicit.platform6.core.dao.Paging<avicit.cbb.techclass.tabledefine.commtempletmanager.domain.CbbTempletCode>) resMapsRb.get("page");
//            Map<String, Object> parameter = (Map<String, Object>) resMapsRb.get("parameter");
//            com.github.pagehelper.Page<Map<String, Object>> getPageBillFormConfigList = billDefineManagerService.getPageBillFormConfigList(page,parameter);
//            responseMsg.setResponseBody(getPageBillFormConfigList);
//            responseMsg.setRetCode("200");
//        } catch (Exception e) {
//            responseMsg.setErrorDesc(e.getMessage());
//            responseMsg.setRetCode("201");
//            e.printStackTrace();
//        }
//        return responseMsg;
//    }




    /**
     *根据formId删除表单配置信息
     * @param resMapsRb
     * @return
     */
    @PostMapping("/deleteFormDataByFormId/v1")
    @ApiOperation(value = "")
    public ResponseMsg deleteFormDataByFormId(@ApiParam(value = "", name = "filebasicmanagerservice")@RequestBody Map<String,Object> resMapsRb) {
        ResponseMsg responseMsg = new ResponseMsg<>();
        try {
            String formId = (String) resMapsRb.get("formId");
            billDefineManagerService.deleteFormDataByFormId(formId);
            responseMsg.setRetCode("200");
        } catch (Exception e) {
            responseMsg.setErrorDesc(e.getMessage());
            responseMsg.setRetCode("201");
            e.printStackTrace();
        }
        return responseMsg;
    }




//    /**
//     *
//     * @param resMapsRb
//     * @return
//     */
//    @PostMapping("/resetFormDataByArchiveFormId/v1")
//    @ApiOperation(value = "")
//    public ResponseMsg resetFormDataByArchiveFormId(@ApiParam(value = "", name = "filevitalizationservice")@RequestBody Map<String,Object> resMapsRb) {
//        ResponseMsg responseMsg = new ResponseMsg<>();
//        try {
//            String sysId = (String) resMapsRb.get("sysId");
//            String nodeId = (String) resMapsRb.get("nodeId");
//            String tableId = (String) resMapsRb.get("tableId");
//            String archiveStatus = (String) resMapsRb.get("archiveStatus");
//            billDefineManagerService.resetFormDataByArchiveFormId(sysId,nodeId,tableId,archiveStatus);
//            responseMsg.setRetCode("200");
//        } catch (Exception e) {
//            responseMsg.setErrorDesc(e.getMessage());
//            responseMsg.setRetCode("201");
//            e.printStackTrace();
//        }
//        return responseMsg;
//    }




//    /**
//     *
//     * @param resMapsRb
//     * @return
//     */
//    @PostMapping("/getPageBillDbList/v1")
//    @ApiOperation(value = "")
//    public ResponseMsg<com.github.pagehelper.Page<Map<String, Object>>> getPageBillDbList(@ApiParam(value = "", name = "filevitalizationservice")@RequestBody Map<String,Object> resMapsRb) {
//        ResponseMsg<com.github.pagehelper.Page<Map<String, Object>>> responseMsg = new ResponseMsg<>();
//        try {
//            avicit.platform6.core.dao.Paging<avicit.cbb.techclass.tabledefine.commtempletmanager.domain.CbbTempletCode> page = (avicit.platform6.core.dao.Paging<avicit.cbb.techclass.tabledefine.commtempletmanager.domain.CbbTempletCode>) resMapsRb.get("page");
//            Map<String, Object> parameter = (Map<String, Object>) resMapsRb.get("parameter");
//            String orgId = (String) resMapsRb.get("orgId");
//            com.github.pagehelper.Page<Map<String, Object>> getPageBillDbList = billDefineManagerService.getPageBillDbList(page,parameter,orgId);
//            responseMsg.setResponseBody(getPageBillDbList);
//            responseMsg.setRetCode("200");
//        } catch (Exception e) {
//            responseMsg.setErrorDesc(e.getMessage());
//            responseMsg.setRetCode("201");
//            e.printStackTrace();
//        }
//        return responseMsg;
//    }




    /**
     *获取部门用户字符串
     * @param resMapsRb
     * @return
     */
    @PostMapping("/getUserDpetString/v1")
    @ApiOperation(value = "")
    public ResponseMsg<String> getUserDpetString(@ApiParam(value = "", name = "filebasicmanagerservice")@RequestBody Map<String,Object> resMapsRb) {
        ResponseMsg<String> responseMsg = new ResponseMsg<>();
        try {
            String tableId = (String) resMapsRb.get("tableId");
            String sysId = (String) resMapsRb.get("sysId");
            String orgId = (String) resMapsRb.get("orgId");
            String getUserDpetString = billDefineManagerService.getUserDpetString(tableId,sysId,orgId);
            responseMsg.setResponseBody(getUserDpetString);
            responseMsg.setRetCode("200");
        } catch (Exception e) {
            responseMsg.setErrorDesc(e.getMessage());
            responseMsg.setRetCode("201");
            e.printStackTrace();
        }
        return responseMsg;
    }




    /**
     *根据tabNodeId获取formId
     * @param resMapsRb
     * @return
     */
    @PostMapping("/getFormIdByTableNodeId/v2")
    @ApiOperation(value = "")
    public ResponseMsg<String> getFormIdByTableNodeId2(@ApiParam(value = "", name = "filebasicmanagerservice")@RequestBody Map<String,Object> resMapsRb) {
        ResponseMsg<String> responseMsg = new ResponseMsg<>();
        try {
            String tableNodeId = (String) resMapsRb.get("tableNodeId");
            String archiveStatus = (String) resMapsRb.get("archiveStatus");
            String getFormIdByTableNodeId = billDefineManagerService.getFormIdByTableNodeId(tableNodeId,archiveStatus);
            responseMsg.setResponseBody(getFormIdByTableNodeId);
            responseMsg.setRetCode("200");
        } catch (Exception e) {
            responseMsg.setErrorDesc(e.getMessage());
            responseMsg.setRetCode("201");
            e.printStackTrace();
        }
        return responseMsg;
    }




    /**
     *根据tabNodeId获取formId
     * @param resMapsRb
     * @return
     */
    @PostMapping("/getFormIdByTableNodeId/v1")
    @ApiOperation(value = "")
    public ResponseMsg<String> getFormIdByTableNodeId(@ApiParam(value = "", name = "filebasicmanagerservice")@RequestBody Map<String,Object> resMapsRb) {
        ResponseMsg<String> responseMsg = new ResponseMsg<>();
        try {
            String tableNodeId = (String) resMapsRb.get("tableNodeId");
            String getFormIdByTableNodeId = billDefineManagerService.getFormIdByTableNodeId(tableNodeId);
            responseMsg.setResponseBody(getFormIdByTableNodeId);
            responseMsg.setRetCode("200");
        } catch (Exception e) {
            responseMsg.setErrorDesc(e.getMessage());
            responseMsg.setRetCode("201");
            e.printStackTrace();
        }
        return responseMsg;
    }




//    /**
//     *
//     * @param resMapsRb
//     * @return
//     */
//    @PostMapping("/getFormShowTableList/v1")
//    @ApiOperation(value = "")
//    public ResponseMsg<List<avicit.cbb.techclass.tabledefine.commtablemanager.domain.CbbTabColumns>> getFormShowTableList(@ApiParam(value = "", name = "filevitalizationservice")@RequestBody Map<String,Object> resMapsRb) {
//        ResponseMsg<List<avicit.cbb.techclass.tabledefine.commtablemanager.domain.CbbTabColumns>> responseMsg = new ResponseMsg<>();
//        try {
//            String tableId = (String) resMapsRb.get("tableId");
//            String id = (String) resMapsRb.get("id");
//            String tableName = (String) resMapsRb.get("tableName");
//            String flag = (String) resMapsRb.get("flag");
//            String sysId = (String) resMapsRb.get("sysId");
//            String orgId = (String) resMapsRb.get("orgId");
//            String deptId = (String) resMapsRb.get("deptId");
//            List<avicit.cbb.techclass.tabledefine.commtablemanager.domain.CbbTabColumns> getFormShowTableList = billDefineManagerService.getFormShowTableList(tableId,id,tableName,flag,sysId,orgId,deptId);
//            responseMsg.setResponseBody(getFormShowTableList);
//            responseMsg.setRetCode("200");
//        } catch (Exception e) {
//            responseMsg.setErrorDesc(e.getMessage());
//            responseMsg.setRetCode("201");
//            e.printStackTrace();
//        }
//        return responseMsg;
//    }




    /**
     *表单数据删除方法
     * @param resMapsRb
     * @return
     */
    @PostMapping("/deleteFormDataById/v1")
    @ApiOperation(value = "")
    public ResponseMsg deleteFormDataById(@ApiParam(value = "", name = "filebasicmanagerservice")@RequestBody Map<String,Object> resMapsRb) {
        ResponseMsg responseMsg = new ResponseMsg<>();
        try {
            String dataid = (String) resMapsRb.get("dataid");
            String tableName = (String) resMapsRb.get("tableName");
            String sysId = (String) resMapsRb.get("sysId");
            String orgId = (String) resMapsRb.get("orgId");
            String deptId = (String) resMapsRb.get("deptId");
            billDefineManagerService.deleteFormDataById(dataid,tableName,sysId,orgId,deptId);
            responseMsg.setRetCode("200");
        } catch (Exception e) {
            responseMsg.setErrorDesc(e.getMessage());
            responseMsg.setRetCode("201");
            e.printStackTrace();
        }
        return responseMsg;
    }




    /**
     *获取表单管理树节点对应表数据个数
     * @param resMapsRb
     * @return
     */
    @PostMapping("/getTableDataCount/v1")
    @ApiOperation(value = "")
    public ResponseMsg<Integer> getTableDataCount(@ApiParam(value = "", name = "filebasicmanagerservice")@RequestBody Map<String,Object> resMapsRb) {
        ResponseMsg<Integer> responseMsg = new ResponseMsg<>();
        try {
            String tableId = (String) resMapsRb.get("tableId");
            Integer getTableDataCount = billDefineManagerService.getTableDataCount(tableId);
            responseMsg.setResponseBody(getTableDataCount);
            responseMsg.setRetCode("200");
        } catch (Exception e) {
            responseMsg.setErrorDesc(e.getMessage());
            responseMsg.setRetCode("201");
            e.printStackTrace();
        }
        return responseMsg;
    }




    /**
     *根据CID 获取FormConfig主键ID
     * @param resMapsRb
     * @return
     */
    @PostMapping("/getCbbTabFormConfigByCid/v1")
    @ApiOperation(value = "")
    public ResponseMsg<String> getCbbTabFormConfigByCid(@ApiParam(value = "", name = "filebasicmanagerservice")@RequestBody Map<String,Object> resMapsRb) {
        ResponseMsg<String> responseMsg = new ResponseMsg<>();
        try {
            String cid = (String) resMapsRb.get("cid");
            String getCbbTabFormConfigByCid = billDefineManagerService.getCbbTabFormConfigByCid(cid);
            responseMsg.setResponseBody(getCbbTabFormConfigByCid);
            responseMsg.setRetCode("200");
        } catch (Exception e) {
            responseMsg.setErrorDesc(e.getMessage());
            responseMsg.setRetCode("201");
            e.printStackTrace();
        }
        return responseMsg;
    }




    /**
     *
     * @param resMapsRb
     * @return
     */
    @PostMapping("/getcbbTabFormConfigById/v1")
    @ApiOperation(value = "")
    public ResponseMsg<CbbTabFormConfig> getcbbTabFormConfigById(@ApiParam(value = "", name = "filebasicmanagerservice")@RequestBody Map<String,Object> resMapsRb) {
        ResponseMsg<CbbTabFormConfig> responseMsg = new ResponseMsg<>();
        try {
            String id = (String) resMapsRb.get("id");
            CbbTabFormConfig getcbbTabFormConfigById = billDefineManagerService.getcbbTabFormConfigById(id);
            responseMsg.setResponseBody(getcbbTabFormConfigById);
            responseMsg.setRetCode("200");
        } catch (Exception e) {
            responseMsg.setErrorDesc(e.getMessage());
            responseMsg.setRetCode("201");
            e.printStackTrace();
        }
        return responseMsg;
    }




    /**
     *获取列代码信息
     * @param resMapsRb
     * @return
     */
    @PostMapping("/getPageBillDetailList/v1")
    @ApiOperation(value = "")
    public ResponseMsg<Page<Map<String, Object>>> getPageBillDetailList(@ApiParam(value = "", name = "filebasicmanagerservice")@RequestBody Map<String,Object> resMapsRb) {
        ResponseMsg<Page<Map<String, Object>>> responseMsg = new ResponseMsg<>();
        try {
            Paging<CbbTempletCode> page = (Paging<CbbTempletCode>) resMapsRb.get("page");
            Map<String, Object> parameter = (Map<String, Object>) resMapsRb.get("parameter");
            String orgId = (String) resMapsRb.get("orgId");
            Page<Map<String, Object>> getPageBillDetailList = billDefineManagerService.getPageBillDetailList(page,parameter,orgId);
            responseMsg.setResponseBody(getPageBillDetailList);
            responseMsg.setRetCode("200");
        } catch (Exception e) {
            responseMsg.setErrorDesc(e.getMessage());
            responseMsg.setRetCode("201");
            e.printStackTrace();
        }
        return responseMsg;
    }




    /**
     *获取列数据源
     * @param resMapsRb
     * @return
     */
    @PostMapping("/getPageCodeDetailList/v1")
    @ApiOperation(value = "")
    public ResponseMsg<Page<Map<String, Object>>> getPageCodeDetailList(@ApiParam(value = "", name = "filebasicmanagerservice")@RequestBody Map<String,Object> resMapsRb) {
        ResponseMsg<Page<Map<String, Object>>> responseMsg = new ResponseMsg<>();
        try {
            Paging<CbbTabColumns> page = (Paging<CbbTabColumns>) resMapsRb.get("page");
            Map<String, Object> parameter = (Map<String, Object>) resMapsRb.get("parameter");
            String orgId = (String) resMapsRb.get("orgId");
            String deptId = (String) resMapsRb.get("deptId");
            Page<Map<String, Object>> getPageCodeDetailList = billDefineManagerService.getPageCodeDetailList(page,parameter,orgId,deptId);
            responseMsg.setResponseBody(getPageCodeDetailList);
            responseMsg.setRetCode("200");
        } catch (Exception e) {
            responseMsg.setErrorDesc(e.getMessage());
            responseMsg.setRetCode("201");
            e.printStackTrace();
        }
        return responseMsg;
    }




    /**
     *根据formId和字段ID判断是否存在表单配置信息
     * @param resMapsRb
     * @return
     */
    @PostMapping("/getformConfigByFormIdAndColId/v1")
    @ApiOperation(value = "")
    public ResponseMsg<Boolean> getformConfigByFormIdAndColId(@ApiParam(value = "", name = "filebasicmanagerservice")@RequestBody Map<String,Object> resMapsRb) {
        ResponseMsg<Boolean> responseMsg = new ResponseMsg<>();
        try {
            String formId = (String) resMapsRb.get("formId");
            String colId = (String) resMapsRb.get("colId");
            Boolean getformConfigByFormIdAndColId = billDefineManagerService.getformConfigByFormIdAndColId(formId,colId);
            responseMsg.setResponseBody(getformConfigByFormIdAndColId);
            responseMsg.setRetCode("200");
        } catch (Exception e) {
            responseMsg.setErrorDesc(e.getMessage());
            responseMsg.setRetCode("201");
            e.printStackTrace();
        }
        return responseMsg;
    }




    /**
     *通过TABLEID取得列信息表格显示对象集合(只用于添加页面)
     * @param resMapsRb
     * @return
     */
    @PostMapping("/getFormShowTableListToAdd/v1")
    @ApiOperation(value = "")
    public ResponseMsg<List<CbbTabColumns>> getFormShowTableListToAdd(@ApiParam(value = "", name = "filebasicmanagerservice")@RequestBody Map<String,Object> resMapsRb) {
        ResponseMsg<List<CbbTabColumns>> responseMsg = new ResponseMsg<>();
        try {
            String tableId = (String) resMapsRb.get("tableId");
            String id = (String) resMapsRb.get("id");
            String tableName = (String) resMapsRb.get("tableName");
            String flag = (String) resMapsRb.get("flag");
            String sysId = (String) resMapsRb.get("sysId");
            String orgId = (String) resMapsRb.get("orgId");
            String deptId = (String) resMapsRb.get("deptId");
            String selectedId = (String) resMapsRb.get("selectedId");
            List<CbbTabColumns> getFormShowTableListToAdd = billDefineManagerService.getFormShowTableListToAdd(tableId,id,tableName,flag,sysId,orgId,deptId,selectedId);
            responseMsg.setResponseBody(getFormShowTableListToAdd);
            responseMsg.setRetCode("200");
        } catch (Exception e) {
            responseMsg.setErrorDesc(e.getMessage());
            responseMsg.setRetCode("201");
            e.printStackTrace();
        }
        return responseMsg;
    }




//    /**
//     *
//     * @param resMapsRb
//     * @return
//     */
//    @PostMapping("/resetFormDataByFormId/v1")
//    @ApiOperation(value = "")
//    public ResponseMsg resetFormDataByFormId(@ApiParam(value = "", name = "filevitalizationservice")@RequestBody Map<String,Object> resMapsRb) {
//        ResponseMsg responseMsg = new ResponseMsg<>();
//        try {
//            String sysId = (String) resMapsRb.get("sysId");
//            String nodeId = (String) resMapsRb.get("nodeId");
//            String tableId = (String) resMapsRb.get("tableId");
//            billDefineManagerService.resetFormDataByFormId(sysId,nodeId,tableId);
//            responseMsg.setRetCode("200");
//        } catch (Exception e) {
//            responseMsg.setErrorDesc(e.getMessage());
//            responseMsg.setRetCode("201");
//            e.printStackTrace();
//        }
//        return responseMsg;
//    }




    /**
     *更新表单配置表信息
     * @param resMapsRb
     * @return
     */
    @PostMapping("/updateCbbTabForm/v1")
    @ApiOperation(value = "")
    public ResponseMsg updateCbbTabForm(@ApiParam(value = "", name = "filebasicmanagerservice")@RequestBody Map<String,Object> resMapsRb) {
        ResponseMsg responseMsg = new ResponseMsg<>();
        try {
            CbbTabFormConfig cbbTabFormConfig = (CbbTabFormConfig) resMapsRb.get("cbbTabFormConfig");
            billDefineManagerService.updateCbbTabForm(cbbTabFormConfig);
            responseMsg.setRetCode("200");
        } catch (Exception e) {
            responseMsg.setErrorDesc(e.getMessage());
            responseMsg.setRetCode("201");
            e.printStackTrace();
        }
        return responseMsg;
    }




//    /**
//     *
//     * @param resMapsRb
//     * @return
//     */
//    @PostMapping("/checkHasForm/v1")
//    @ApiOperation(value = "")
//    public ResponseMsg<Boolean> checkHasForm(@ApiParam(value = "", name = "filevitalizationservice")@RequestBody Map<String,Object> resMapsRb) {
//        ResponseMsg<Boolean> responseMsg = new ResponseMsg<>();
//        try {
//            String tableId = (String) resMapsRb.get("tableId");
//            String nodeId = (String) resMapsRb.get("nodeId");
//            Boolean checkHasForm = billDefineManagerService.checkHasForm(tableId,nodeId);
//            responseMsg.setResponseBody(checkHasForm);
//            responseMsg.setRetCode("200");
//        } catch (Exception e) {
//            responseMsg.setErrorDesc(e.getMessage());
//            responseMsg.setRetCode("201");
//            e.printStackTrace();
//        }
//        return responseMsg;
//    }




//    /**
//     *
//     * @param resMapsRb
//     * @return
//     */
//    @PostMapping("/checkHasForm/v1")
//    @ApiOperation(value = "")
//    public ResponseMsg<Boolean> checkHasForm(@ApiParam(value = "", name = "filevitalizationservice")@RequestBody Map<String,Object> resMapsRb) {
//        ResponseMsg<Boolean> responseMsg = new ResponseMsg<>();
//        try {
//            String tableId = (String) resMapsRb.get("tableId");
//            String nodeId = (String) resMapsRb.get("nodeId");
//            String archiveStatus = (String) resMapsRb.get("archiveStatus");
//            Boolean checkHasForm = billDefineManagerService.checkHasForm(tableId,nodeId,archiveStatus);
//            responseMsg.setResponseBody(checkHasForm);
//            responseMsg.setRetCode("200");
//        } catch (Exception e) {
//            responseMsg.setErrorDesc(e.getMessage());
//            responseMsg.setRetCode("201");
//            e.printStackTrace();
//        }
//        return responseMsg;
//    }




    /**
     *根据deptId查找deptName
     * @param resMapsRb
     * @return
     */
    @PostMapping("/getDeptNameById/v1")
    @ApiOperation(value = "")
    public ResponseMsg<String> getDeptNameById(@ApiParam(value = "", name = "filebasicmanagerservice")@RequestBody Map<String,Object> resMapsRb) {
        ResponseMsg<String> responseMsg = new ResponseMsg<>();
        try {
            String id = (String) resMapsRb.get("id");
            String getDeptNameById = billDefineManagerService.getDeptNameById(id);
            responseMsg.setResponseBody(getDeptNameById);
            responseMsg.setRetCode("200");
        } catch (Exception e) {
            responseMsg.setErrorDesc(e.getMessage());
            responseMsg.setRetCode("201");
            e.printStackTrace();
        }
        return responseMsg;
    }




//    /**
//     *
//     * @param resMapsRb
//     * @return
//     */
//    @PostMapping("/setModelColumn/v1")
//    @ApiOperation(value = "")
//    public ResponseMsg setModelColumn(@ApiParam(value = "", name = "filevitalizationservice")@RequestBody Map<String,Object> resMapsRb) {
//        ResponseMsg responseMsg = new ResponseMsg<>();
//        try {
//            Map<String, Object> param = (Map<String, Object>) resMapsRb.get("param");
//            billDefineManagerService.setModelColumn(param);
//            responseMsg.setRetCode("200");
//        } catch (Exception e) {
//            responseMsg.setErrorDesc(e.getMessage());
//            responseMsg.setRetCode("201");
//            e.printStackTrace();
//        }
//        return responseMsg;
//    }




    /**
     *表单数据更新方法
     * @param resMapsRb
     * @return
     */
    @PostMapping("/updateFormData/v1")
    @ApiOperation(value = "")
    public ResponseMsg updateFormData(@ApiParam(value = "", name = "filebasicmanagerservice")@RequestBody Map<String,Object> resMapsRb) {
        ResponseMsg responseMsg = new ResponseMsg<>();
        try {
            String json = (String) resMapsRb.get("json");
            String sysId = (String) resMapsRb.get("sysId");
            String tableName = (String) resMapsRb.get("tableName");
            String nodeName = (String) resMapsRb.get("nodeName");
            String nodeId = (String) resMapsRb.get("nodeId");
            String id = (String) resMapsRb.get("id");
            String orgId = (String) resMapsRb.get("orgId");
            String deptId = (String) resMapsRb.get("deptId");
            billDefineManagerService.updateFormData(json,sysId,tableName,nodeName,nodeId,id,orgId,deptId);
            responseMsg.setRetCode("200");
        } catch (Exception e) {
            responseMsg.setErrorDesc(e.getMessage());
            responseMsg.setRetCode("201");
            e.printStackTrace();
        }
        return responseMsg;
    }




    /**
     *获取列信息对象集合
     * @param resMapsRb
     * @return
     */
    @PostMapping("/getFormShowList/v1")
    @ApiOperation(value = "")
    public ResponseMsg<List<CbbTabColumns>> getFormShowList(@ApiParam(value = "", name = "filebasicmanagerservice")@RequestBody Map<String,Object> resMapsRb) {
        ResponseMsg<List<CbbTabColumns>> responseMsg = new ResponseMsg<>();
        try {
            String tableId = (String) resMapsRb.get("tableId");
            String flag = (String) resMapsRb.get("flag");
            List<CbbTabColumns> getFormShowList = billDefineManagerService.getFormShowList(tableId,flag);
            responseMsg.setResponseBody(getFormShowList);
            responseMsg.setRetCode("200");
        } catch (Exception e) {
            responseMsg.setErrorDesc(e.getMessage());
            responseMsg.setRetCode("201");
            e.printStackTrace();
        }
        return responseMsg;
    }




    /**
     *获取基本字段生成方式为通用代码的字段集合
     * @param resMapsRb
     * @return
     */
    @PostMapping("/getRuleCodeList/v1")
    @ApiOperation(value = "")
    public ResponseMsg<Map<String, Map<String, String>>> getRuleCodeList(@ApiParam(value = "", name = "filebasicmanagerservice")@RequestBody Map<String,Object> resMapsRb) {
        ResponseMsg<Map<String, Map<String, String>>> responseMsg = new ResponseMsg<>();
        try {
            List<CbbTabColumns> list = (List<CbbTabColumns>) resMapsRb.get("list");
            String flag = (String) resMapsRb.get("flag");
            String sysId = (String) resMapsRb.get("sysId");
            String orgId = (String) resMapsRb.get("orgId");
            Map<String, Map<String, String>> getRuleCodeList = billDefineManagerService.getRuleCodeList(list,flag,sysId,orgId);
            responseMsg.setResponseBody(getRuleCodeList);
            responseMsg.setRetCode("200");
        } catch (Exception e) {
            responseMsg.setErrorDesc(e.getMessage());
            responseMsg.setRetCode("201");
            e.printStackTrace();
        }
        return responseMsg;
    }




    /**
     *根据sysCode查找sysName
     * @param resMapsRb
     * @return
     */
    @PostMapping("/getSysNameByCode/v1")
    @ApiOperation(value = "")
    public ResponseMsg<String> getSysNameByCode(@ApiParam(value = "", name = "filebasicmanagerservice")@RequestBody Map<String,Object> resMapsRb) {
        ResponseMsg<String> responseMsg = new ResponseMsg<>();
        try {
            String code = (String) resMapsRb.get("code");
            String getSysNameByCode = billDefineManagerService.getSysNameByCode(code);
            responseMsg.setResponseBody(getSysNameByCode);
            responseMsg.setRetCode("200");
        } catch (Exception e) {
            responseMsg.setErrorDesc(e.getMessage());
            responseMsg.setRetCode("201");
            e.printStackTrace();
        }
        return responseMsg;
    }




//    /**
//     *
//     * @param resMapsRb
//     * @return
//     */
//    @PostMapping("/getModelColumn/v1")
//    @ApiOperation(value = "")
//    public ResponseMsg<String> getModelColumn(@ApiParam(value = "", name = "filevitalizationservice")@RequestBody Map<String,Object> resMapsRb) {
//        ResponseMsg<String> responseMsg = new ResponseMsg<>();
//        try {
//            Map<String, Object> param = (Map<String, Object>) resMapsRb.get("param");
//            String getModelColumn = billDefineManagerService.getModelColumn(param);
//            responseMsg.setResponseBody(getModelColumn);
//            responseMsg.setRetCode("200");
//        } catch (Exception e) {
//            responseMsg.setErrorDesc(e.getMessage());
//            responseMsg.setRetCode("201");
//            e.printStackTrace();
//        }
//        return responseMsg;
//    }




    /**
     *根据userId查找userName
     * @param resMapsRb
     * @return
     */
    @PostMapping("/getUserNameById/v1")
    @ApiOperation(value = "")
    public ResponseMsg<String> getUserNameById(@ApiParam(value = "", name = "filebasicmanagerservice")@RequestBody Map<String,Object> resMapsRb) {
        ResponseMsg<String> responseMsg = new ResponseMsg<>();
        try {
            String id = (String) resMapsRb.get("id");
            String getUserNameById = billDefineManagerService.getUserNameById(id);
            responseMsg.setResponseBody(getUserNameById);
            responseMsg.setRetCode("200");
        } catch (Exception e) {
            responseMsg.setErrorDesc(e.getMessage());
            responseMsg.setRetCode("201");
            e.printStackTrace();
        }
        return responseMsg;
    }




    /**
     *表单数据新增方法
     * @param resMapsRb
     * @return
     */
    @PostMapping("/insertFormData/v1")
    @ApiOperation(value = "")
    public ResponseMsg insertFormData(@ApiParam(value = "", name = "filebasicmanagerservice")@RequestBody Map<String,Object> resMapsRb) {
        ResponseMsg responseMsg = new ResponseMsg<>();
        try {
            String json = (String) resMapsRb.get("json");
            String sysId = (String) resMapsRb.get("sysId");
            String tableName = (String) resMapsRb.get("tableName");
            String nodeName = (String) resMapsRb.get("nodeName");
            String nodeId = (String) resMapsRb.get("nodeId");
            String orgId = (String) resMapsRb.get("orgId");
            String deptId = (String) resMapsRb.get("deptId");
            String loginUserId = (String) resMapsRb.get("loginUserId");
            String loginIp = (String) resMapsRb.get("loginIp");
            billDefineManagerService.insertFormData(json,sysId,tableName,nodeName,nodeId,orgId,deptId,loginUserId,loginIp);
            responseMsg.setRetCode("200");
        } catch (Exception e) {
            responseMsg.setErrorDesc(e.getMessage());
            responseMsg.setRetCode("201");
            e.printStackTrace();
        }
        return responseMsg;
    }






}
